﻿// JavaScript Document
var MAX_WIDTH  = 250;
var MAX_HEIGHT = 350;
var CONTAINER_HEIGHT = 250;
function resizeImage(source_img, max_width, max_height, container_height)
{
	var img = new Image();
	img.src = source_img.src;
	if(!max_width || parseInt(max_width)<=0)
	{
		max_width = MAX_WIDTh;
	}
	if(!max_height || parseInt(max_height)<=0)
	{
		max_height = MAX_HEIGHT;
	}
	if(!container_height || parseInt(container_height) <= 0)
	{
		container_height = CONTAINER_HEIGHT;
	}
	if(img.width > 0 && img.height > 0)
	{
		var img_rate = 1;
		if((max_width / img.width) < (max_height/img.height))
		{
			img_rate = max_width / img.width;
		}
		else
		{
			img_rate = max_height / img.height;
		}
		if(img_rate <= 1)
		{
			source_img.width = img.width * img_rate;
			source_img.height = img.height * img_rate;
			source_img.style.marginTop = (container_height - source_img.height)/2+'px';
		}
	}
}

function tkshop(exlevel) 
{ 
	var rankstar; 
	if(exlevel >=1 && exlevel < 6) { 
		if(exlevel == 1){ 
			document.write ("<img src='http://image.taobao.com/helpcenter/xin"+exlevel+".gif'>"); //1心 
		} 
		else if(exlevel !=5 ) { 
		document.write ("<img src='http://image.taobao.com/helpcenter/xinxin"+exlevel+".gif'>"); 
		} else { 
			document.write ("<img src='http://image.taobao.com/helpcenter/xinxin5.gif'>"); //5心 
		}
	} else if(exlevel >10 && exlevel <= 20) { 
		rankstar = exlevel - 10; 
		if(rankstar > 5)rankstar = 5;
		document.write ("<img src='http://pics.taobaocdn.com/newrank/s_blue_"+rankstar+".gif'/>"); //钻 
	} 
	else if(exlevel >100 && exlevel <= 105){ 
		rankstar = exlevel - 100; 
		document.write ("<img src='http://pics.taobaocdn.com/newrank/s_cap_"+rankstar+".gif'/>"); //皇冠 
	} else if(exlevel >1000 && exlevel <= 1005){ 
		rankstar = exlevel - 1000; 
		document.write ("<img src='http://pics.taobaocdn.com/newrank/s_crown_"+rankstar+".gif'/>"); //金冠 
	}
} 
